<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>设备管理</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/jsp/css/main.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/jsp/css/default.css">

<link rel="stylesheet"
	href="https://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<script
	src="https://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script
	src="https://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="js/jquery-1.5.1.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		
		

		$('#sect1').blur(function(){
			var sect1=document.getElementById('sect1').value;
			getSect1(sect1)
		})
		
		$('#search').blur(function(){
			var search=document.getElementById('search').value;
			getSearch(search)
		})
	})
	
	function Status6(){
		var a = document.getElementById("${equip.eqipId}").innerHTML;
		alert(a);
	}
	
	function getSearch(search){
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/getSearch.action',
			data:'search='+search,
			success:function(data){
				
			}
		})
	}

	function getSect1(sect1){
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/getSect1.action',
			data:'sect1='+sect1,
			success:function(data){
				
			}
		})
	}
	function getradio() {

		var radioval = $('#wrap input[name="payMethod"]:checked ').val();
		alert(radioval)
		setSwift(radioval)
	}
	
	function setSwift(data){
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/setSwift.action',
			data:'swift='+data,
			success:function(data){
				setList()
			}			
		})		
	}
	
	function getList(){
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/getList.action',
			success:function(data){
				init()
			}
		})
	}
	
	function nextPage(end) {
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/nextPage.action',
			data:'end='+end,
			success:function(data){
				init()
			}
		})
	}
	
	function lastPage(begin){
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/lastPage.action',
			data:'begin='+begin,
			success:function(data){
				init()
			}
		})
	}
	function setList(){
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/setList.action',
			success:function(data){
				init()
			}
		})
	}
	
	function setIndex(){
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/setIndex.action',
			success:function(data){
				init()
			}
		})
	}
	
	function searchEquip(){
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/searchEquip.action',
			success:function(data){
				init()
			}
		})
	}	
	
	function init() {
		/* window.location.href="${pageContext.request.contextPath}/equipment/getList.action"; */
		$.ajax({
			type : 'post',
			url : '${pageContext.request.contextPath }/equipment/getList.action',
			dataType : 'html',
			success : function(data) {
				$("#showContent").html(data);
			}
		});
	
	}
	
	function getradioo(data) {

		
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/setSwift1.action',
			data:'swift='+data,
			success:function(data){
				setList()
			}			
		})		
	}
	
	
	function startAll() {
		
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/startAll.action',
			success:function(data){
				setList()
			}			
		})		
	}
	
   function closeAll() {
		
		$.ajax({
			type:'post',
			url:'${pageContext.request.contextPath}/equipment/closeAll.action',
			success:function(data){
				setList()
			}			
		})		
	}
</script>
</head>
<body id="showContent">




	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span12">

				<div id="container"
					style="width: 1200px; height: 30px; margin-top: 30px; margin-left: 50px;">

					<div id="myAlert" class="alert alert-success"
						style="width: 1050px; height: 70px;">
						<a href="#" class="close" data-dismiss="alert">&times;</a>
						<c:forEach items="${searchList}" var="search">
							<label style="font-size: 20px;">安装地址:&nbsp;&nbsp;&nbsp;${search.install}</label>
						</c:forEach>
					</div>




					<div id="header" style="width: 1000px; height: 50px;">

						<select name="option1" id="sect1" class="form-control"
							style="height: 30px; float: left; width: 150px;">
							<option value="equipId">设备ID</option>
							<option value="equipName">设备名称</option>
						</select> <input type="text" id="search" class="form-control"
							style="height: 30px; float: left; width: 150px;">
						<button onclick="searchEquip()" class="btn btn-info"
							style="height: 30px; float: left; width: 100px;">查询</button>
						<button type="reset" class="btn btn-info"
							style="height: 30px; float: left; width: 100px;">重置</button>

					</div>



					<div id="menu"
						style="background-color:; height: 600px; width: 400px; float: left; margin-top: 30px;">
						<button onclick="setList()" class="btn btn-success">显示全部数据</button>
						<button onclick="startAll()" class="btn btn-info">一键启动</button>
						<button onclick="closeAll()" class="btn btn-info">一键关闭</button>

						<hr>


						<table class="table table-hover"
							style="height: 500px; width: 400px;">
							<thead>
								<tr>
									<td>设备ID</td>
									<td>运行状态</td>
									<td>开关</td>

								</tr>
							</thead>
							<tbody>
								<c:forEach items="${equipList}" var="equip" begin="${begin}"
									end="${end-1}">
									<tr>
										<td>${equip.eqipId}</td>
										<td>${equip.status}</td>
										<td>${equip.swift}</td>

									</tr>
								</c:forEach>
							<tbody>
						</table>


					</div>

					<div id="content"
						style="background-color:; height: 500px; width: 600px; float: left; margin-left: 50px;">
						<table class="table table-hover">
							<thead>
								<tr>
									<td>设备名称</td>
									<td>序号</td>
									<td>设备ID</td>
									<td>额定电流</td>
									<td>额定电压</td>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${equipList}" var="equip" begin="${begin}"
									end="${end-1}">
									<tr>
										<td>${equip.eqipName}</td>
										<td>${equip.serial}</td>
										<td>${equip.eqipId}</td>
										<td>${equip.elecRate}</td>
										<td>${equip.elecVol}</td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
						<hr>
						<p>共有&nbsp;${size}&nbsp;条记录，当前&nbsp;${page}-&nbsp;${currentPage}页</p>

						<div id="footType">
							<div id="pageType" style="float: right; margin-right: 50px;">
								<ul class="pager">
									<li><a href="javascript:void(0)" onclick="setIndex()">首页</a></li>
									<li><a href="javascript:void(0)"
										onclick="lastPage(${begin})">上一页</a></li>
									<li><a href="javascript:void(0)"
										onclick="nextPage(${end-1})">下一页</a></li>
								</ul>
							</div>
						</div>
					</div>
				</div>





			</div>
		</div>
	</div>
</body>
</html>